﻿using _06.原型模式.Interface;
using _06.原型模式.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06.原型模式
{
    public class Client
    {
        public void Start()
        {
            IPhone iphone1 = new ApplePhone();
            iphone1.CPU = "最初的三星S5L8900";
            iphone1.Memory = 1;
            iphone1.Write("iphone1");
            Console.WriteLine($"iphone1.Battery.Capacity={iphone1.Battery.Capacity} maA");

            IPhone iphone15 = iphone1.Clone();//浅拷贝
            iphone15.Write("iphone15");
            Console.WriteLine($"iphone15.Battery.Capacity={iphone15.Battery.Capacity} maA");

            //修改iphone15对象的内容
            iphone15.CPU = "芯片：A16仿生芯片,16核神经引擎，5核GPU、6核CPU";
            iphone15.Memory = 512;
            iphone15.Battery.Capacity++;

            iphone15.Write("iphone15修改后");
            iphone1.Write("iphone1");

            Console.WriteLine($"iphone15.Battery.Capacity={iphone15.Battery.Capacity} maA");
            Console.WriteLine($"iphone1.Battery.Capacity={iphone1.Battery.Capacity} maA");

            Console.WriteLine("---------------------漂亮的分割线------------------------");

            IPhone iphone16 = iphone1.DeepClone();//深拷贝
            iphone16.Write("iphone16");
            Console.WriteLine($"iphone16.Battery.Capacity={iphone16.Battery.Capacity} maA");

            iphone16.CPU = "12核CPU,10核GPU";
            iphone16.Memory = 1024;
            iphone16.Battery.Capacity++;

            iphone16.Write("iphone16修改后");
            iphone1.Write("iphone1");
            Console.WriteLine($"iphone16.Battery.Capacity={iphone16.Battery.Capacity} maA");
            Console.WriteLine($"iphone1.Battery.Capacity={iphone1.Battery.Capacity} maA");
        }
    }
}
